from tensorflow.keras import layers, models, optimizers, losses

x_data = [[73., 80., 75.],
          [93., 88., 93.],
          [89., 91., 90.],
          [96., 98., 100.],
          [73., 66., 70.]]
y_data = [[152.],
          [185.],
          [180.],
          [196.],
          [142.]]

#keras底层实现, models.Model建立模型
input = layers.Input(shape=(3))  #layers.Input输入维度3
out = layers.Dense(1)(input)  #layers.Dense单元个数=1
model = models.Model(input, out)  #使用model.Model(输入，输出)

#模型配置
model.compile(optimizer=optimizers.Adam(0.05), loss=losses.mse)

# 查看模型结构
model.summary()

#fit方法训练模型, 返回历史数据history
history = model.fit(x_data, y_data, epochs=100)
loss = history.history['loss']   #返回损失值

import matplotlib.pyplot as plt
plt.plot(loss)
plt.show()